package singleton_pattern;

/**
 * 单例模式经典代码
 */
public class SingleTon {

    private static final SingleTon singleton = new SingleTon();

    //限制产生多个对象
    private SingleTon() {
    }

    //通过该方法获取实例对象
    public static SingleTon getInstance() {
        return singleton;
    }

    //类中其他方法，尽量是static
    public static void doSomething() {
        System.out.println("this is a singleInstance");
    }
}
